package entity;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Vector;

public class SignalGroup implements Serializable {
    public double time;
    public String device;
    public String type = "Monitor";
    public int[] range = new int[2];

    public List<Double> value;

    /*
     * time 时间戳   /1000 转为python中的时间戳
     */
    public SignalGroup(long time, String device) {
        this.time = time / 1000.0;
        this.device = device;
//        this.range = new Vector<>();
        range[1] = -1;
        this.value = new Vector<>();
    }

    public SignalGroup(String device) {
        this(new Date().getTime(), device);
    }

    public SignalGroup addSignal(int range, double value) {
//        this.range.add(range);
        this.range[1]++;
        this.value.add(value);
        return this;
    }

    public SignalGroup addSignal(double value) {
//        this.range.add(range);
        this.range[1]++;
        this.value.add(value);
        return this;
    }

    @Override
    public String toString() {
        return String.format("SignalGroup{" +
                "time=%f" +
                ", device='" + device + '\'' +
                ", range=" + Arrays.toString(range) +
                ", value=" + value +
                '}', time);
    }
}